﻿<%@ Page
    Language="C#"
    AutoEventWireup="true"
    CodeBehind="AddProducts.aspx.cs"
    Inherits="ModernShopping.User.AddProducts" MasterPageFile="~/ModernShopping.Master" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor" TagPrefix="cc1" %>
<%@ Register Src="~/WebUserControls/UCCountDown.ascx" TagName="Countdown" TagPrefix="MyUserControls" %>
<%@ Register Src="~/WebUserControls/UCPopup.ascx" TagName="Popup" TagPrefix="MyUserControls" %>
<asp:Content runat="server" ContentPlaceHolderID="HeaderContent">
    <script type="text/javascript" src="../Scripts/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="../Scripts/jquery.validate.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#form1").validate({
                rules: {
                    <%=TxtProductName.UniqueID%>: {
                        required: true,
                        minlength: 6
                    },
                    <%=TxtMadeIn.UniqueID%>: {
                        required: true,
                        minlength: 2
                    },
                    <%=TxtPrice.UniqueID%>: {
                        required: true,
                        minlength: 2
                    }
                },
                messages: {
                    <%=TxtProductName.UniqueID%>: {
                        required: "Bạn không được để trống mục này!",
                        minlength: "Tên sản phẩm phải từ 6 kí tự trở lên."
                    },
                    <%=TxtMadeIn.UniqueID%>: {
                        required: "Bạn không được để trống mục này!",
                        minlength: "Xuất xứ phải từ 2 kí tự trở lên."
                    },
                    <%=TxtPrice.UniqueID%>: {
                        required: "Bạn không được để trống mục này!",
                        minlength: "Xuất xứ phải từ 2 kí tự trở lên."
                    }
                }
            });
        });
    </script>
    </asp:Content>

<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="MainContent">
    <div class="div-center">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="title">
            <asp:Label ID="Label1"
                runat="server"
                Text="THÊM SẢN PHẨM" Width="100%" BorderStyle="None" />
        </div>
        <div class="add-product">
            <div style="width: 90%; margin: 30px auto 30px auto;">
                <table class="auto-style1">
                    <tr>
                        <td colspan="4">
                            <asp:Label ID="Label2"
                                CssClass="subheader"
                                runat="server"
                                Text="THÔNG TIN"
                                Width="100%" BorderStyle="None"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="table-title-col">
                            <asp:Label ID="Label4" runat="server" Text="Tên sản phẩm:"></asp:Label>
                        </td>
                        <td class="table-input-col" colspan="3">
                            <asp:TextBox ID="TxtProductName" runat="server" CssClass="textbox" Width="95%" MaxLength="50"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td class="table-title-col">
                            <asp:Label ID="Label5" runat="server" Text="Xuất xứ:"></asp:Label>
                        </td>
                        <td class="table-input-col">
                            <asp:TextBox ID="TxtMadeIn" runat="server" CssClass="textbox" MaxLength="15"></asp:TextBox>
                            <ajaxToolkit:FilteredTextBoxExtender
                                runat="server"
                                FilterType="LowercaseLetters, UppercaseLetters,Custom"
                                Enabled="True"
                                ValidChars=", "
                                TargetControlID="TxtMadeIn" />
                        </td>
                        <td class="table-title-col">
                            <asp:Label ID="Label6" runat="server" Text="Giá bán:"></asp:Label>
                        </td>
                        <td class="table-input-col">
                            <asp:TextBox ID="TxtPrice" runat="server" CssClass="textbox"></asp:TextBox>
                            <ajaxToolkit:FilteredTextBoxExtender
                                runat="server"
                                FilterType="Numbers"
                                Enabled="True"
                                TargetControlID="TxtPrice" />
                        </td>
                    </tr>
                    <tr>
                        <td class="table-title-col">
                            <asp:Label ID="Label14" runat="server" Text="Ảnh mô tả:"></asp:Label>
                        </td>
                        <td class="table-input-col" colspan="3">
                            <asp:FileUpload ID="FileUpload" runat="server" CssClass="textbox" />
                            <asp:RegularExpressionValidator ID="regexValidator" runat="server"
                                ControlToValidate="FileUpload"
                                ErrorMessage=" Chỉ chấp nhận định dạng ảnh (.jpg, .bmp, .png, .gif)"
                                ValidationExpression="^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w].*))(.jpg|.JPG|.gif|.GIF|.jpeg|.JPEG|.bmp|.BMP|.png|.PNG)$"
                                ForeColor="Red"></asp:RegularExpressionValidator>
                        </td>
                    </tr>
                    <tr>
                        <td class="table-title-col" colspan="4">
                            <asp:Label ID="Label12"
                                CssClass="subheader"
                                runat="server"
                                Text="NƠI BÁN"
                                Width="100%"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <asp:UpdatePanel runat="server">
                                <ContentTemplate>
                                    <table style="width: 100%">
                                        <tr>
                                            <td class="table-title-col" style="width: 145px;">
                                                <asp:Label ID="Label13" runat="server" Text="Cửa hàng:"></asp:Label>
                                            </td>
                                            <td class="table-input-col">
                                                <asp:DropDownList ID="cboListStore" runat="server" CssClass="textbox" AutoPostBack="True" OnSelectedIndexChanged="cboListStore_SelectedIndexChanged"></asp:DropDownList>
                                            </td>
                                            <td style="width: 145px;">&nbsp;</td>
                                            <td class="table-input-col">
                                                <asp:Button ID="btnInsertStore" runat="server" Text="THÊM CỬA HÀNG" CssClass="button" OnClick="btnInsertStore_Click" UseSubmitBehavior="False" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="table-title-col" style="width: 145px;">
                                                <asp:Label ID="Label3" runat="server" Text="Địa chỉ:"></asp:Label>
                                            </td>
                                            <td class="table-input-col" colspan="3">
                                                <asp:Label runat="server" ID="lblAddress" Width="100%"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="4">
                                                <asp:GridView ID="gvMyStores" runat="server" AutoGenerateColumns="False" BorderColor="#2C7C00" BorderWidth="1px" PageSize="5" Width="100%" ShowHeaderWhenEmpty="True" AllowPaging="True" OnPageIndexChanging="gvMyStores_PageIndexChanging">
                                                    <AlternatingRowStyle BackColor="#FFFF99" />
                                                    <Columns>
                                                        <asp:TemplateField HeaderText="STT">
                                                            <ItemTemplate>
                                                                <%# Container.DataItemIndex+1 %>
                                                            </ItemTemplate>
                                                            <ItemStyle Width="50px" />
                                                        </asp:TemplateField>
                                                        <asp:BoundField DataField="Name" HeaderText="TÊN CỬA HÀNG">
                                                            <ItemStyle CssClass="gridview-row-style" HorizontalAlign="Left" VerticalAlign="Middle" Width="250px" />
                                                        </asp:BoundField>
                                                        <asp:BoundField DataField="Address" HeaderText="ĐIẠ CHỈ">
                                                            <ItemStyle CssClass="gridview-row-style" HorizontalAlign="Left" VerticalAlign="Middle" />
                                                        </asp:BoundField>
                                                        <asp:TemplateField HeaderText="THAO TÁC" ShowHeader="False">
                                                            <ItemTemplate>
                                                                <asp:LinkButton ID="lbRemove" runat="server" CausesValidation="False" CommandArgument='<%# Eval("Code")%>' OnClick="lbRemove_Click" Text="Xóa"></asp:LinkButton>
                                                            </ItemTemplate>
                                                            <ItemStyle Width="100px" />
                                                        </asp:TemplateField>
                                                    </Columns>
                                                    <HeaderStyle BackColor="#00A8DF" Font-Italic="False" Font-Size="15pt" ForeColor="White" Height="35px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                    <RowStyle Font-Size="13pt" Height="35px" HorizontalAlign="Center" VerticalAlign="Middle" />
                                                </asp:GridView>
                                            </td>
                                        </tr>
                                    </table>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="cboListStore" EventName="SelectedIndexChanged" />
                                    <asp:AsyncPostBackTrigger ControlID="btnInsertStore" EventName="Click" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <asp:Label ID="Label9"
                                CssClass="subheader"
                                runat="server"
                                Text="MÔ TẢ"
                                Width="100%"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <cc1:Editor ID="edtDescription" runat="server" Height="250px" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4">
                            <asp:Label ID="Label11"
                                CssClass="subheader"
                                runat="server"
                                Width="100%"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="table-title-col">&nbsp;</td>
                        <td class="table-input-col">&nbsp;</td>
                        <td class="table-title-col">&nbsp;</td>
                        <td class="table-input-col">
                            <asp:Button ID="btnAdd" runat="server" CssClass="button" Text="THÊM" OnClick="btnAdd_Click" />
                        </td>
                    </tr>
                    <tr>
                        <td class="table-title-col">&nbsp;</td>
                        <td class="table-input-col">&nbsp;</td>
                        <td class="table-title-col">&nbsp;</td>
                        <td class="table-input-col">&nbsp;</td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <MyUserControls:Countdown runat="server" ID="Countdown" />
    <MyUserControls:Popup runat="server" ID="MyPopup" />
</asp:Content>

